#include <iostream>
#include <string>
#include <vector>
#include <functional>

void print(const std::string& str, int num) 
{
    std::cout << str << num << std::endl;
}

int main()
{
    // print("hello");
    // auto func = std::bind(print, "Hello");
    // func();

    // auto func = std::bind(print, "Hello ", std::placeholders::_1);//占位符，可以给要传的参数预留位置
    // func(11);

    using Task = std::function<void()>;
    std::vector<Task> array;
    array.push_back(std::bind(print, "Hello ", 10));// 没有placeholders，不传参
    array.push_back(std::bind(print, "Hello ", 20));
    array.push_back(std::bind(print, "nihao ", 30));
    array.push_back(std::bind(print, "nihao ", 40));
    for (auto& f : array) {
        f();
    }
    return 0;
}